﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ArgusPCLib.BitConversion
{
	public static class ArgusLibExtensions
	{
		#region UInt8
		public static ushort ToUInt16(this byte value) { return (ushort)value; }
		public static uint ToUInt32(this byte value) { return (uint)value; }
		public static ulong ToUInt64(this byte value) { return (ulong)value; }

		public static sbyte ToInt8(this byte value) { return (sbyte)value; }
		public static short ToInt16(this byte value) { return (short)value.ToUInt16(); }
		public static int ToInt32(this byte value) { return (int)value.ToUInt32(); }
		public static long ToInt64(this byte value) { return (long)value.ToUInt64(); }
		#endregion

		#region Int8
		public static byte ToUInt8(this sbyte value) { return (byte)value; }
		public static ushort ToUInt16(this sbyte value) { return ((byte)value).ToUInt16(); }
		public static uint ToUInt32(this sbyte value) { return ((byte)value).ToUInt32(); }
		public static ulong ToUInt64(this sbyte value) { return ((byte)value).ToUInt64(); }

		public static short ToInt16(this sbyte value) { return ((byte)value).ToInt16(); }
		public static int ToInt32(this sbyte value) { return ((byte)value).ToInt32(); }
		public static long ToInt64(this sbyte value) { return ((byte)value).ToInt64(); }
		#endregion

		#region UInt16
		public static byte ToUInt8(this ushort value) { return (byte)value; }
		public static uint ToUInt32(this ushort value) { return (uint)value; }
		public static ulong ToUInt64(this ushort value) { return (ulong)value; }

		public static sbyte ToInt8(this ushort value) { return (sbyte)value.ToUInt8(); }
		public static short ToInt16(this ushort value) { return (short)value; }
		public static int ToInt32(this ushort value) { return (int)value.ToUInt32(); }
		public static long ToInt64(this ushort value) { return (long)value.ToUInt64(); }
		#endregion

		#region Int16
		public static byte ToUInt8(this short value) { return ((ushort)value).ToUInt8(); }
		public static ushort ToUInt16(this short value) { return (ushort)value; }
		public static uint ToUInt32(this short value) { return ((ushort)value).ToUInt32(); }
		public static ulong ToUInt64(this short value) { return ((ushort)value).ToUInt64(); }

		public static sbyte ToInt8(this short value) { return ((ushort)value).ToInt8(); }
		public static int ToInt32(this short value) { return ((ushort)value).ToInt32(); }
		public static long ToInt64(this short value) { return ((ushort)value).ToInt64(); }
		#endregion

		#region UInt32
		public static byte ToUInt8(this uint value) { return (byte)value; }
		public static ushort ToUInt16(this uint value) { return (ushort)value; }
		public static ulong ToUInt64(this uint value) { return (ulong)value; }

		public static sbyte ToInt8(this uint value) { return (sbyte)value.ToUInt8(); }
		public static short ToInt16(this uint value) { return (short)value.ToUInt16(); }
		public static int ToInt32(this uint value) { return (int)value; }
		public static long ToInt64(this uint value) { return (long)value.ToUInt64(); }
		#endregion

		#region Int32
		public static byte ToUInt8(this int value) { return ((uint)value).ToUInt8(); }
		public static ushort ToUInt16(this int value) { return ((uint)value).ToUInt16(); }
		public static uint ToUInt32(this int value) { return (uint)value; }
		public static ulong ToUInt64(this int value) { return ((uint)value).ToUInt64(); }

		public static sbyte ToInt8(this int value) { return ((uint)value).ToInt8(); }
		public static short ToInt16(this int value) { return ((uint)value).ToInt16(); }
		public static long ToInt64(this int value) { return ((uint)value).ToInt64(); }
		#endregion

		#region UInt64
		public static byte ToUInt8(this ulong value) { return (byte)value; }
		public static ushort ToUInt16(this ulong value) { return (ushort)value; }
		public static uint ToUInt32(this ulong value) { return (uint)value; }

		public static sbyte ToInt8(this ulong value) { return (sbyte)value.ToUInt8(); }
		public static short ToInt16(this ulong value) { return (short)value.ToUInt16(); }
		public static int ToInt32(this ulong value) { return (int)value.ToUInt32(); }
		public static long ToInt64(this ulong value) { return (long)value; }
		#endregion

		#region Int64
		public static byte ToUInt8(this long value) { return ((ulong)value).ToUInt8(); }
		public static uint ToUInt16(this long value) { return ((ulong)value).ToUInt16(); }
		public static uint ToUInt32(this long value) { return ((ulong)value).ToUInt32(); }
		public static ulong ToUInt64(this long value) { return (ulong)value; }

		public static sbyte ToInt8(this long value) { return ((ulong)value).ToInt8(); }
		public static short ToInt16(this long value) { return ((ulong)value).ToInt16(); }
		public static int ToInt32(this long value) { return ((ulong)value).ToInt32(); }
		#endregion
	}
}
